/**
 * Copyright (C) 2009-2012, KingHool.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses.
 */
package com.kinghool.smodel.test;

import java.util.List;

import com.kinghool.ebos.commons.utils.Utils;
import com.kinghool.smodel.io.bean.annotation.Array;
import com.kinghool.smodel.io.bean.annotation.Attribute;
import com.kinghool.smodel.io.bean.annotation.Bean;

/**
 * 
 * @Author Allen Deng(dengtailin@gmail.com)
 */
@Bean(name = "customer")
public class Customer {
	@Attribute
	private String id;
	@Attribute
	private String name;

	@Array(child = "address", add = "addAddress")
	private List<Address> addresses = Utils.newList();

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Address> getAddresses() {
		return addresses;
	}

	public void setAddresses(List<Address> addresses) {
		for (Address address : addresses) {
			addAddress(address);
		}
	}
	
	public void addAddress(Address address) {
		address.setCustomer(this);
		
		this.addresses.add(address);
	}
}
